/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  							 script_combat.h

	$Header: /heroes4/script_combat.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( SCRIPT_COMBAT_H_INCLUDED )
#define SCRIPT_COMBAT_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "script_action_type.h"
#include "script_branch_action.h"
#include "script_target_type.h"
#include "shared_ptr.h"

struct t_adv_map_point;
class  t_creature_array;

// --------------------------------------------------------------------------
// t_script_combat class
// --------------------------------------------------------------------------

class t_script_combat : public t_script_branch_action
{
public:
	// Types
	typedef t_creature_array		t_opponents;
	typedef t_script_army_target	t_target;

	// Constructors/Destructor
	t_script_combat();
	t_script_combat( t_script_combat const & other );
	virtual ~t_script_combat();

	// Member functions
	virtual void		execute(t_script_context_hero const& context) const;
	virtual void		execute(t_script_context_town const& context) const;
	virtual void		execute(t_script_context_object const& context) const;
	virtual void		execute(t_script_context_army const& context) const;
	virtual void		execute(t_script_context_global const& context) const;

	t_opponents const &	get_opponents() const;
	t_target			get_target() const;
	virtual bool		read(
							std::streambuf &	stream,
							int					version );
	virtual bool		read_from_map(
							std::streambuf &	stream,
							int					format_version );
	virtual bool		write( std::streambuf & stream ) const;

	// Operators
	t_script_combat &	operator=( t_script_combat const & other );

private:
	// Data members
	t_target					m_target;
	t_shared_ptr< t_opponents >	m_opponents_ptr;

	bool	do_action(t_adventure_map* map, t_creature_array* array, t_player* owner, 
					  t_adv_map_point const& point) const;
};

// --------------------------------------------------------------------------
// t_script_combat inline members
// --------------------------------------------------------------------------

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline t_script_combat::t_opponents const &
t_script_combat::get_opponents() const
{
	return *m_opponents_ptr;
}

// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
inline t_script_combat::t_target t_script_combat::get_target() const
{
	return m_target;
}

SPECIALIZE_SCRIPT_ACTION( k_script_action_combat, t_script_combat );

#endif // !defined( SCRIPT_COMBAT_H_INCLUDED )
